<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Group
 *
 * @author bom
 */
class Group extends Zend_Db_Table_Abstract {
    //put your code here
    protected $_name = 'user_group';
    protected $_primary = 'group_id';

    public function getAllGroup($page = 0, $order = "group_name asc"){
        $tb = Zend_Db_Table::getDefaultAdapter();
        $tb->setFetchMode(Zend_Db::FETCH_OBJ);
        
        $select = $tb->select()->from(array('user_group'))->order($order);
        
        $paginator = Zend_Paginator::factory($select);
    	$paginator->setItemCountPerPage(Zend_Registry::get('page_size'));
    	$paginator->setCurrentPageNumber($page); 
    	
        return $paginator;
    }
    
    public function getGroupById($id){
        $groupRowset = $this->fetchAll($this->select()->where('group_id = ?', $id));
        $group = $groupRowset->current();
        return $group;
    } 
}
?>
